package se.study.thread;

/**
 * @Author: tiger
 * @Date:2018/5/10
 * @Description:
 */
public class ThreadStatus {
    public static void main(String[] args) {
        try {
            System.out.println("print");
            Thread.sleep(1000);
            System.out.println("print");

            Thread thread = new Thread(() -> System.out.println("线程名称：" + Thread.currentThread().getName()));
            thread.setDaemon(true);
            boolean daemon0 = thread.isDaemon();
            System.out.println(thread.getName() + "是否为后台线程：" + daemon0);
            thread.start();

            String name = Thread.currentThread().getName();
            System.out.println("线程名称：" + name);

            // 是否为后台线程（守护线程）
            boolean daemon = Thread.currentThread().isDaemon();
            System.out.println(Thread.currentThread().getName() + "是否为后台线程：" + daemon);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
